use std::collections::HashMap;

pub fn new_count_distinct(input_str: &str) -> usize {
    let mut result: usize = 0;
    if input_str.is_empty() {
        return result;
    } else {
        let splits = input_str.split(",");
        let mut kv: HashMap<&str, usize> = HashMap::new();

        splits.for_each(|token| {
            if kv.contains_key(token) {
                let old_count = kv.get(token).unwrap();
                kv.insert(token, old_count + 1);
            } else {
                kv.insert(token, 1);
            }
        });

        result = kv.len();
    }

    result
}
